﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.Windows.Media;

namespace InstaMe.CustomControls
{
    public partial class CircularProgressBar : UserControl
    {
        public CircularProgressBar()
        {
            InitializeComponent();
            this.hinh.Begin();
        }

        public static readonly DependencyProperty TextProperty = DependencyProperty.Register("MyText",
        typeof(string), typeof(CircularProgressBar), new PropertyMetadata(SetValue));

        public static readonly DependencyProperty MyBackgroundProperty = DependencyProperty.Register("Background",
        typeof(Brush), typeof(CircularProgressBar), new PropertyMetadata(SetValue));

        public string MyText
        {
            get { return (string)this.GetValue(TextProperty); }
            set
            {
                this.SetValue(TextProperty, value);
            }
        }

        public Brush Background
        {
            get { return (Brush)this.GetValue(MyBackgroundProperty); }
            set
            {
                this.SetValue(MyBackgroundProperty, value);
            }
        }

        private static void SetValue(object sender, DependencyPropertyChangedEventArgs args)
        {

        }

        public static readonly DependencyProperty InnerMarginProperty = DependencyProperty.Register(
                                          "InnerMargin",
                                          typeof(Thickness),
                                          typeof(CircularProgressBar),
                                          new PropertyMetadata(default(Thickness), OnMarginPropertyChanged));

        private static void OnMarginPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ((CircularProgressBar)d).image.Margin = ((CircularProgressBar)d).InnerMargin;
        }

        public Thickness InnerMargin
        {
            get
            {
                return (Thickness)GetValue(InnerMarginProperty);
            }
            set
            {
                SetValue(InnerMarginProperty, value);
            }
        }
    }
}
